package com.chance.cc.crawler.development.bootstrap.tianya.tianyanews;

import com.chance.cc.crawler.core.CrawlerEnum;
import com.chance.cc.crawler.core.filter.FilterUtils;
import com.chance.cc.crawler.core.record.CrawlerRequestRecord;
import com.chance.cc.crawler.development.controller.DevCrawlerController;

public class TianYaStart {
    private static final String DOMAIN = "tianya";
    private static final String SITE = "product";
    private static final String START_URL = "https://search.tianya.cn/bbs?q=nike&pn=1&s=4";

    public static void main(String[] args) {
        CrawlerRequestRecord crawlerRecord = CrawlerRequestRecord.builder()
                .startPageRequest(DOMAIN, CrawlerEnum.CrawlerRequestType.turnPage)
                .domain(DOMAIN)
                .httpUrl(START_URL)
                .recordKey(START_URL)
                .releaseTime(System.currentTimeMillis())
                .filter(CrawlerEnum.CrawlerRecordFilter.keyOrDateRange)
                .addFilterInfo(FilterUtils.memoryFilterKeyInfo(DOMAIN))
                .addFilterInfo(FilterUtils.dateRangeFilterInfo(7*24,null))
                .resultLabelTag(CrawlerEnum.CrawlerDataType.article)
                .resultLabelTag(CrawlerEnum.CrawlerDataType.interaction)
                .resultLabelTag(CrawlerEnum.CrawlerDataType.comment)
                .build();
        crawlerRecord.tagsCreator().bizTags().addDomain(DOMAIN);
        crawlerRecord.tagsCreator().bizTags().addSite(SITE);

        DevCrawlerController.builder()
                .triggerInfo(DOMAIN,DOMAIN,System.currentTimeMillis(),DOMAIN)
                .crawlerRequestQueue(DevCrawlerController.devRequestQueue(DOMAIN))
                .fileResultPipeline("F:\\changxi\\web_data\\tianya_nike.log",false)
                .consoleResultPipeline()
                .requestRecord(crawlerRecord)
                .build("com.chance.cc.crawler.development.scripts.tianya.tianyanews.TianYaScript")
                .start();
    }
}
